/*-------------------------------------------------------------------------
 *
 * extension.h
 *		扩展管理命令（创建/删除扩展）。
 *
 *
 * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
 * Portions Copyright (c) 1994, Regents of the University of California
 *
 * src/include/commands/extension.h
 *
 *-------------------------------------------------------------------------
 */
#ifndef EXTENSION_H
#define EXTENSION_H

#include "catalog/objectaddress.h"
#include "parser/parse_node.h"


/*
 * creating_extension 仅在执行 CREATE EXTENSION 或 ALTER
 * EXTENSION UPDATE 命令时为真。它指示 recordDependencyOnCurrentExtension()
 * 为每个由扩展脚本创建的 SQL 对象注册对当前 pg_extension 对象的依赖关系。
 * 它还指示 performDeletion()
 * 在不跟踪的情况下删除这些依赖关系，以便扩展脚本可以在不必显式解除
 * 它们与扩展的关联的情况下删除成员对象。
 */
extern PGDLLIMPORT bool creating_extension;
extern PGDLLIMPORT Oid CurrentExtensionObject;


extern ObjectAddress CreateExtension(ParseState *pstate, CreateExtensionStmt *stmt);

extern void RemoveExtensionById(Oid extId);

extern ObjectAddress InsertExtensionTuple(const char *extName, Oid extOwner,
										  Oid schemaOid, bool relocatable, const char *extVersion,
										  Datum extConfig, Datum extCondition,
										  List *requiredExtensions);

extern ObjectAddress ExecAlterExtensionStmt(ParseState *pstate, AlterExtensionStmt *stmt);

extern ObjectAddress ExecAlterExtensionContentsStmt(AlterExtensionContentsStmt *stmt,
													ObjectAddress *objAddr);

extern Oid	get_extension_oid(const char *extname, bool missing_ok);
extern char *get_extension_name(Oid ext_oid);
extern bool extension_file_exists(const char *extensionName);

extern ObjectAddress AlterExtensionNamespace(const char *extensionName, const char *newschema,
											 Oid *oldschema);

#endif							/* EXTENSION_H */
